import pygame
from image import load_image

#modelo
class Robo(pygame.sprite.Sprite):
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.image, self.rect = load_image('robot.png')
        screen = pygame.display.get_surface()
        self.area = screen.get_rect()
        self.speed = 20
        self.reinit()

    def reinit(self):
        self.movepos = [0,0]
        self.rect.midright = self.area.center

    def update(self):
        newpos = self.rect.move(self.movepos)
        if self.area.contains(newpos):
            self.rect = newpos
        self.movepos = [0,0]

    def moveup(self):
        self.movepos[1] = self.movepos[1] - (self.speed)

    def movedown(self):
        self.movepos[1] = self.movepos[1] + (self.speed)

    def moveleft(self):
        self.movepos[0] = self.movepos[1] - (self.speed)

    def moveright(self):
        self.movepos[0] = self.movepos[0] + (self.speed)

